home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / datasheets and manuals / Hardware / WHT / scsi / dsr_sources_2_2001 / flush < prev    next >
Text File  |  2006-10-19  |  3KB  |  115 lines

  1. * Procedure FLUSH
  2. *
  3. *   This procedure will check the open file to see if
  4. *   it's buffer needs to be written to disk.  If it
  5. *   does, it will either read the 512 byte block from
  6. *   disk and overwrite the 256 byte sector or if the
  7. *   buffer is 512 bytes, it will just write out the
  8. *   512 bytes.
  9. *
  10. *   Input:
  11. *      R5 points to the open file cache
  12. *      R12 points to the 1st CRU bit of RAM bank select
  13. *
  14.  
  15. FLUSH  LDCR @B02,4            Select RAM bank 2
  16.        MOV  @60(R5),R1        Get the modified flags
  17.        JNE  FLUSH1
  18.        RT                     Buffer not modified - Return
  19.  
  20. FLUSH1 LI   R0,512            Assume a 512 byte sector
  21.        LI   R1,SECBUF
  22.        MOV  @50(R5),R7        Get AU of the buffer
  23.        MOV  R6,R3
  24.        SRL  R3,8
  25.        SLA  R3,1
  26.        LDCR @B04,4            Select RAM bank 4
  27.        MPY  @SAUTBL(R3),R7
  28.        LDCR @B02,4
  29.        A    @52(R5),R8        Add in sector within AU
  30.        JNC  FLUSH2
  31.        INC  R7
  32. FLUSH2 SRL  R8,1
  33.        JNC  FLUSH3
  34.        AI   R1,>100
  35. FLUSH3 SRL  R7,1
  36.        JNC  FLUSH4
  37.        AI   R8,>8000
  38. FLUSH4 C    @58(R5),@ZERO     Check buffer size
  39.        JNE  FLUSH6            If 512 byte buffer, don't bother reading
  40.        LI   R0,256
  41.        LDCR @ZERO,4           Select RAM bank 0
  42.        BLWP @BANKIT           Read the block from disk
  43.        DATA SCSIRD
  44.        JEQ  FLUSH6
  45. FLUSH5 BL   @DSRERR
  46.        DATA >0600             Device error
  47.  
  48. FLUSH6 LDCR @B02,4
  49.        MOV  @6(R5),R4         Get buffer address
  50.        MOVB @3(R5),R2         Get buffer bank
  51.  
  52. * Copy the file buffer to the SCSI I/O buffer and clear
  53. * out the buffer.
  54. *
  55.  
  56. FLUSH7 LDCR R2,4
  57.        MOV  *R4,R3
  58.        CLR  *R4+
  59.        LDCR @ZERO,4
  60.        MOV  R3,*R1+
  61.        DECT R0
  62.        JNE  FLUSH7
  63.  
  64.        BLWP @BANKIT           Write back out to disk
  65.        DATA SCSIWT
  66.        JNE  FLUSH5
  67.  
  68. * Now write the FDR back out to disk
  69. * A later version of the DSR make have two flags.  One
  70. * for buffer modified and one for FDR modified.  For
  71. * now, we write out the buffer and FDR together.
  72. *
  73.        LDCR @B02,4            Select RAM bank 2
  74.        MOV  @48(R5),R7        Get AU of FDR
  75.        MOV  R6,R3
  76.        SRL  R3,8
  77.        SLA  R3,1
  78.        LDCR @B04,4            Select RAM bank 4
  79.        MPY  @SAUTBL(R3),R7
  80.        LI   R1,SECBUF
  81.  
  82.        SRL  R8,1
  83.        JNC  FLUSH8
  84.        AI   R4,>100
  85. FLUSH8 SRL  R7,1
  86.        JNC  FLUSH9
  87.        AI   R8,>8000
  88.  
  89. FLUSH9 LDCR @ZERO,4           Select RAM bank 0
  90.        BLWP @BANKIT           Read old block
  91.        DATA SCSIRD
  92.        JNE  FLUSH5
  93.  
  94.        LDCR @B02,4            Select RAM bank 2
  95.        MOV  @4(R5),R4         Get FDR address
  96.        MOVB @2(R5),R2         Get FDR bank
  97.        LI   R0,256
  98.  
  99. * Copy the FDR to the SCSI I/O buffer
  100. *
  101. FLUS10 LDCR R2,4
  102.        MOV  *R4+,R3
  103.        LDCR @ZERO,4
  104.        MOV  R3,*R1+
  105.        DECT R0
  106.        JNE  FLUS10
  107.  
  108.        BLWP @BANKIT
  109.        DATA SCSIWT
  110.        JNE  FLUSH5
  111.  
  112.        LDCR @B02,4            Select RAM bank 2
  113.        CLR  @60(R5)           Clear modified flags
  114.        RT
  115.